package com.dabai.iot.core.api;

import com.dabai.iot.core.entity.ProductTopicEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 产品服务 stub
 *
 * @author kev1n
 */
@Slf4j
@RequiredArgsConstructor
public class RemoteProductServiceStub implements RemoteProductService {

    private final RemoteProductService remoteProductService;

    @Override
    public Long productCount(String tenantId) {
        try {
            return remoteProductService.productCount(tenantId);
        } catch (Exception e) {
            log.warn("Dubbo - 产品服务未找到");
            return 0L;
        }
    }

    @Override
    public List<ProductTopicEntity> getTopicList(Long productId, String topicSourceType, String topicDirection) {
        try {
            return remoteProductService.getTopicList(productId, topicSourceType, topicDirection);
        } catch (Exception e) {
            log.warn("Dubbo - 产品服务未找到");
            return List.of();
        }
    }

}
